/**
 * css 动画
 */
const cssMethods = {
  //渐入，渐出实现 
  defaultShow(that, param, px, opacity, isArray = false) {
    var animation = wx.createAnimation({
      //持续时间800ms
      duration: 800,
      timingFunction: 'ease',
    });
    //var animation = this.animation
    animation.opacity(opacity).step();
    if (isArray) {
      return animation.export();
    } else {
      //将param转换为key
      var json = '{"' + param + '":""}'
      json = JSON.parse(json);
      json[param] = animation.export()
      //设置动画
      that.setData(json)
    }

  },

  //滑动渐入渐出
  slideupshow(that, param, px, opacity, isArray = false) {
    var animation = wx.createAnimation({
      duration: 800,
      timingFunction: 'ease',
    });
    animation.translateY(px).opacity(opacity).step();
    //设置动画
    if (isArray) {
      return animation.export();
    } else {
      //将param转换为key
      var json = '{"' + param + '":""}'
      json = JSON.parse(json);
      json[param] = animation.export();
      that.setData(json)
    }

  },
  //向右滑动渐入渐出
  sliderightshow(that, param, px, opacity, isArray = false) {
    var animation = wx.createAnimation({
      duration: 800,
      timingFunction: 'ease',
    });
    animation.translateX(px).opacity(opacity).step();
    if (isArray) {
      return animation.export();
    } else {
      //将param转换为key
      var json = '{"' + param + '":""}'
      json = JSON.parse(json);
      json[param] = animation.export();
      //设置动画
      that.setData(json)
    }
  }
}
export default cssMethods